package com.ruoyi.zhgd.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhgd.service.IZjOuterService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 对外接口提供
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zhgd/outer")
public class ZjOuterController extends BaseController {

    private final IZjOuterService iZjOuterService;

    /**
     * 设备数量统计
     * @param projectNumber 项目编号
     * @param sectionNumber 标段编号
     * @return
     */
    @SaIgnore
    @GetMapping("/deviceCount")
    public R<Map<String, List<Map<String, Object>>>> deviceCount(@RequestParam(value = "projectNumber") String projectNumber, @RequestParam(value = "sectionNumber", required = false) String sectionNumber) {
        Map<String, Object> params = new HashMap<>();
        params.put("projectNumber", projectNumber);
        if (ObjectUtils.isNotEmpty(sectionNumber)) {
            params.put("sectionNumber", sectionNumber);
        } else {
            params.put("sectionNumber", null);
        }
        return R.ok(iZjOuterService.deviceCount(params));
    }

}
